#ifndef __OGRE_RENDER_HPP__
# define __OGRE_RENDER_HPP__

# include "core/scene_node.hpp"
# include "core/object.hpp"
# include "misc/config.hpp"

# include <boost/scoped_ptr.hpp>
# include <boost/tuple/tuple.hpp>

# include <map>
# include <string>

namespace Ogre
{
    class Root;
    class RenderSystem;
    class RenderWindow;
    class Viewport;
    class SceneManager;
    class Camera;
    class SceneNode;
}

class ogre_logger_t;

class render_impl_t
{
public:

    /**
     * @brief Construct named render.
     */
    render_impl_t(const config_t &config);
    ~render_impl_t();

    void prepare_render();
    void cleanup_render();

    boost::tuple<boost::shared_ptr<scene_node_t>, vector3_t> create_entity(object_class_t &obj_class);

    scalar_t get_per_phisics_scale();

    void render_one_frame();

    /** --- Render API --- */
    /** {@ */

    /**
     * Camera
     */
    void create_camera(const std::string &name);
    void set_back_color(const color_t &color);
    void set_near_clip_dist(float dist);
    void set_far_clip_dist(float dist);
    void set_camera(const vector3_t &pos);
    void camera_look_at(const vector3_t &dir);

    /**
     * Light
     */
    void set_ambient_light(const color_t &color);
    void create_directional_light(const color_t &diffuse_color, const color_t &specular_color, const vector3_t &direction);

    /** @} */

private:

    bool vertical_sync_;

    bool full_screen_;

    size_t size_x_;
    size_t size_y_;

    /// Ogre log redirector
    boost::scoped_ptr<ogre_logger_t> ogre_logger_;

    /// Ogre Root.
    boost::scoped_ptr<Ogre::Root> ogre_root_;

    boost::shared_ptr<scene_node_t> root_node_;

    /// Rendering system objects.
    Ogre::RenderSystem *render_system_;
    Ogre::RenderWindow *render_window_;
    Ogre::Viewport *view_port_;

    /// Scene management objects.
    Ogre::SceneManager *scene_manager_;
    Ogre::Camera *camera_;
    Ogre::SceneNode *camera_node_;

    typedef std::map<std::string, std::string> render_par_map_t;
    render_par_map_t render_window_params_;

    std::string scene_type_;
    };

#endif //__OGRE_RENDER_HPP__
